package org.iiitb.assignment.extension;



import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.eclipse.ui.part.ViewPart;
import org.iiitb.assignment.wizards.WizardMain;

public class MainView extends ViewPart {

	Label label;
	Label result;
	Button button;
	MainView view = this;

	public MainView() {
		// TODO Auto-generated constructor stub
	}

	@Override
	public void createPartControl(final Composite parent) {
		// TODO Auto-generated method stub

		parent.setLayout(new GridLayout(1, true));

		label = new Label(parent, SWT.NONE);
		label.setText("Press Start to Enter the travel details:");

		button = new Button(parent,SWT.NONE);
		button.setText("Start");

		result = new Label(parent, SWT.NONE);
		result.setText("");

		button.addSelectionListener(new SelectionListener() {

			@Override
			public void widgetSelected(SelectionEvent e) {
				// TODO Auto-generated method stub
				System.out.println("View Success");
				result.setText("");
				new WizardDialog(parent.getShell(), new WizardMain(view)).open();
			}

			@Override
			public void widgetDefaultSelected(SelectionEvent e) {
				// TODO Auto-generated method stub

			}
		});
	}

	@Override
	public void setFocus() {
		// TODO Auto-generated method stub

	}

	public void updateResult(String result) {
		this.result.setText(result);
		this.result.getParent().layout();
	}

}
